/*
 * Author:   W.SH
 */
package com.wgg.crawler.model;

import java.io.Serializable;
import java.util.Map;
import org.apache.http.HttpHost;

/**
 * 〈一句话功能简述〉<br> 
 * 〈功能详细描述〉
 *
 *  @author W.SH
 */
public class CrawlerDatum {

    public static final long UNFETCHED_TIME = 0; //未抓取的时间值
    
    long lastFetchTime; //最后一次抓取时间
    Site site;
    String method;
    
    public CrawlerDatum(String url) {
        this(new Site(url), UNFETCHED_TIME);
    }
    
    public CrawlerDatum(Site site) {
        this(site, UNFETCHED_TIME);
    }
    
    public CrawlerDatum(Site site, long lastFetchTime) {
        this.site = site;
        this.lastFetchTime = lastFetchTime;
    }

    public long getLastFetchedTime() {
        return lastFetchTime;
    }

    public void setLastFetchTime(long lastFetchTime) {
        this.lastFetchTime = lastFetchTime;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public Site getSite() {
        return site;
    }

    public void setSite(Site site) {
        this.site = site;
    }
    
    @SuppressWarnings({ "serial", "rawtypes" })
    public static class Site implements Serializable,Comparable {
        
        private String url;
        private String userAgent;
        private Integer prority;
        private Map<String, String> cookies;
        private Map<String, Object> wireSign;
        private Map<String, String> headers;
        private String host;
        private HttpHost httpHost;

        public Site(String url){
            this(url, null);
        }

        public Site(String url, String userAgent) {
            this(url, userAgent, null, null, null);
        }
        
        public Site(String url, String userAgent, Map<String, String> cookies, Map<String, String> headers, String host) {
            this.url = url;
            this.userAgent = userAgent;
            this.cookies = cookies;
            this.headers = headers;
            this.host = host;
        }
        
        @Override
        public int compareTo(Object o) {
            return 0;
        }
        
        @Override
        public String toString() {
            return "Site{" +
                    "url='" + url + '\'' +
                    ", userAgent='" + userAgent + '\'' +
                    ", prority=" + prority +
                    ", cookies=" + cookies +
                    ", wireSign=" + wireSign +
                    ", headers=" + headers +
                    ", host='" + host + '\'' +
                    ", httpHost=" + httpHost +
                    '}';
        }

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public String getUserAgent() {
            return userAgent;
        }

        public void setUserAgent(String userAgent) {
            this.userAgent = userAgent;
        }

        public Integer getPrority() {
            return prority;
        }

        public void setPrority(Integer prority) {
            this.prority = prority;
        }

        public Map<String, String> getCookies() {
            return cookies;
        }

        public void setCookies(Map<String, String> cookies) {
            this.cookies = cookies;
        }

        public Map<String, Object> getWireSign() {
            return wireSign;
        }

        public void setWireSign(Map<String, Object> wireSign) {
            this.wireSign = wireSign;
        }

        public Map<String, String> getHeaders() {
            return headers;
        }

        public void setHeaders(Map<String, String> headers) {
            this.headers = headers;
        }

        public String getHost() {
            return host;
        }

        public void setHost(String host) {
            this.host = host;
        }

        public HttpHost getHttpHost() {
            return httpHost;
        }

        public void setHttpHost(HttpHost httpHost) {
            this.httpHost = httpHost;
        }
        
    }
    
}
